<?php

	//设置PHPExcel类库的include path
	set_include_path('.'. PATH_SEPARATOR .
                 'D:\Zeal\PHP_LIBS' . PATH_SEPARATOR .
                 get_include_path());
	include"../../Lib/Classes/PHPExcel.php";
	//excel 5
	include '../../Lib/Classes/PHPExcel/Writer/Excel5.php';
	
	$objExcel=new PHPExcel();
	
	$objWriter=new PHPExcel_Writer_Excel5($objExcel);
	
	$objProps = $objExcel->getProperties();   
	$objProps->setCreator("Zeal Li");   
	$objProps->setLastModifiedBy("Zeal Li");   
	$objProps->setTitle("Office XLS Test Document");   
	$objProps->setSubject("Office XLS Test Document, Demo");   
	$objProps->setDescription("Test document, generated by PHPExcel.");   
	$objProps->setKeywords("office excel PHPExcel");   
	$objProps->setCategory("Test");
	//设置sheet
	$objExcel->setActiveSheetIndex(0);  
	$objActSheet = $objExcel->getActiveSheet();
	$objActSheet->setTitle('测试Sheet');
	
	$objActSheet->mergeCells('A1:P1');
	$objActSheet->mergeCells('A2:E2');  	
	$objActSheet->mergeCells('L2:P2');  	
	$objActSheet->mergeCells('A3:A4');  	
	$objActSheet->mergeCells('B3:D3');  	
	$objActSheet->mergeCells('E3:E4');  	
	$objActSheet->mergeCells('G3:I3');  	
	$objActSheet->mergeCells('J3:L3');  	
	$objActSheet->mergeCells('M3:O3');  	
	$objActSheet->mergeCells('F3:F4');  	
	$objActSheet->mergeCells('P3:P4');  	
	$objActSheet->setCellValue('A1','湖南农业大学东方科技学院全日制普通本科生毕业论文（设计）供选题情况表');
	//获取格式
	$objStyleA1 = $objActSheet->getStyle('A1');   
	$objFontA1 = $objStyleA1->getFont();
	//字体格式	
	$objFontA1->setName('黑体')->setSize(16);
	$objAlignA1 = $objStyleA1->getAlignment(); 
	$objAlignA1->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
	//设置边框    
	// $objStyler= $objActSheet->getStyle('A2:O10');
	// $objBorder = $objStyler->getBorders();    
	// $objBorder->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);    
	// $objBorder->getTop()->getColor()->setARGB('FFFF0000'); // color  
	// $objBorder->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);    
	// $objBorder->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);    
	// $objBorder->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
	 
$applyFromArray1=
	array(
		  'borders' => array(
								'bottom'	=> array('style' => PHPExcel_Style_Border::BORDER_THIN),
								'right'		=> array('style' => PHPExcel_Style_Border::BORDER_THIN),
								'left'		=> array('style' => PHPExcel_Style_Border::BORDER_THIN),
								'top'		=> array('style' => PHPExcel_Style_Border::BORDER_THIN),
							)
		 );
	$alphabet=array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P');
	for($i=0;$i<16;$i++){
	
		$objExcel->getActiveSheet()->getStyle($alphabet[$i].'3')->applyFromArray($applyFromArray1);
		$objExcel->getActiveSheet()->getStyle($alphabet[$i].'4')->applyFromArray($applyFromArray1);
	}
//	$objFontA1->getColor()->setARGB('FF999999');
	
	//输出
	$outputFileName = "供选题情况表2.xls";    
	header("Content-Type: application/force-download");    
	header("Content-Type: application/octet-stream");    
	header("Content-Type: application/download");    
	header('Content-Disposition:inline;filename="'.$outputFileName.'"');    
	header("Content-Transfer-Encoding: binary");    
	header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    
	header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");    
	header("Cache-Control: must-revalidate, post-check=0, pre-check=0");    
	header("Pragma: no-cache");    
	$objWriter->save('php://output');
?>